package com.itheima.organization.dao;

import com.itheima.aom.pojo.Aom;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

@Repository
public interface AomMapper extends Mapper<Aom> {

    /**
     * 建立
     * @param aomid
     * @param amoorderid
     */
    @Insert("INSERT INTO `t_aom_aom_order`(`aomid`, `amoorderid`) VALUES (#{aomid}, #{amoorderid})")
    void insertTo(@Param("aomid")Long aomid, @Param("amoorderid")Long amoorderid);

    /**
     * 更新农业组织与订单中间表,建立农业组织与最新订单的中间关系
     * @param aomid
     * @param amoorderid
     */
    @Update("UPDATE `t_aom_aom_order` SET `amoorderid` = #{amoorderid} WHERE `aomid` = #{aomid}")
    void updateTo(@Param("aomid")Long aomid, @Param("amoorderid")Long amoorderid);

    /**
     * 根据id查询中间表信息
     * @param aomid
     * @return
     */
    @Select("Select * from t_aom_aom_order where aomid=#{aomid}")
    List<Map> selectByAomId(Long aomid);
}
